﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DALScolarite 
{
    public partial class scolarite_enseigneunite
    {
        uvtmoyEntities ent;
        public List<EtudiantModules> Etudiants(int groupe, string ideltdiplome, string idunite)
        {
            ent = new uvtmoyEntities();
            var query = from s in ent.scolarite_enseigneunite
                        join enseignant in ent.scolarite_enseignants on s.idEnseignants equals enseignant.idEnseignants
                        join unite in ent.scolarite_ensunites on s.idunite equals unite.idunite
                        join cohorte in ent.scolarite_contextcohorts on s.idContextCohorts equals cohorte.idContextCohorts
                        join grp in ent.scolarite_groupeclass on cohorte.idContextCohorts equals grp.idContextCohorts
                        join inscriptetud in ent.scolarite_inscriptgroupeclass on grp.idGroupeClass equals inscriptetud.idGroupeClass
                        join inscript in ent.scolarite_inscription on inscriptetud.idInscription equals inscript.idInscription
                        join etudiant in ent.scolarite_etudiants on inscript.idetudiants equals etudiant.idetudiants
                        join classe in ent.scolarite_classes on grp.idClasse equals classe.idClasse
                        where unite.idEltDiplome == ideltdiplome && grp.idGroupeClass == groupe && unite.idunite == idunite
                        select new EtudiantModules { 

                            idetudiants = etudiant.idetudiants,
                            idInscription = inscript.idInscription,
                            NomFR = etudiant.NomFR,
                            PrenomFR = etudiant.PrenomFR,
                            email = etudiant.email,
                            cin= etudiant.cin,

                            idEnseignants=enseignant.idEnseignants,
                            NomFR_ens = enseignant.NomFR,
                            PrenomFR_ens = enseignant.PrenomFR,
                            Email_ens = enseignant.Email,
                            cin_ens = enseignant.CIN,
                             
                            idGroupeClass= grp.idGroupeClass,
                            NomDeGroupe = grp.NomDeGroupe, 

                            Module = unite.labelfr,
                            label = classe.label,

                            sex=etudiant.sex 

                        };
            if (query.Any())
            {

                return query.ToList();
            }
            else
            {
                return null;
            }
        }

    }
}
